# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Matt Smith <mcs@darkregion.net>
# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Contributor: Iggy Jackson <iggy@theiggy.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=nsd
pkgver=4.3.2
pkgrel=0
pkgdesc="Authoritative only, high performance and simple DNS server"
url="https://www.nlnetlabs.nl/projects/nsd"
arch="all"
license="BSD-3-Clause"
makedepends="openssl-dev libevent-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-doc $pkgname-dbg $pkgname-openrc"
pkgusers="nsd"
pkggroups="nsd"
source="https://www.nlnetlabs.nl/downloads/nsd/nsd-$pkgver.tar.gz
	nsd.initd
	config.patch
	"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--sbindir=/usr/sbin \
		--mandir=/usr/share/man \
		--with-user=nsd \
		--with-pidfile=/run/nsd/nsd.pid \
		--with-xfrdir=/var/db/nsd \
		--enable-ratelimit \
		--enable-ratelimit-default-is-off
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname

	install -d "$pkgdir"/usr/share/doc/$pkgname
	cp -a "$builddir"/doc/* "$builddir"/contrib \
		"$pkgdir"/usr/share/doc/$pkgname/

	install -d -m 755 -o nsd -g nsd "$pkgdir"/var/db/nsd
	rm -fr "$pkgdir"/run
}

sha512sums="0423aeddc7f60e04718b6ee0954fbdc274576b6ef61472324256e5db696f41e47899b645cbc4d6d8cc2a7dd00190b72f3ef0476c4640dbb80d36ec39f1c9f5c8  nsd-4.3.2.tar.gz
bc2b27d98b99db067c7c4b152ee40ae81b8ee66989f873ca0c21f57333c3734bb342866f68d5837f10bb56cb598fafc794095c02b8bc97ef6dace450cae526a6  nsd.initd
4c107bba33785a031f29c2d078419c8f0858c94a2488e192a6e76085e7135755352446d350ad4561b02beb767fecd488ac710fc1d2ba9e19a9c42f484331bd3c  config.patch"
